** Table 5: Asset eligibility
clear

** Loading data
*cd // *Your directory path goes here* //
import excel .\Data\Special_DailyAverages_Pseudo.xlsx, firstrow allstring

* Step 1: Organize the data:
gen dateSTATA = date(substr(refdate,1,11),"MDY")
format dateSTATA %td
drop refdate
gen year = year(dateSTATA)
gen month = month(dateSTATA)

destring volweightedrate volsum hypeligible, replace
encode isin, gen(isincat)
drop isin
label define order  1 ON  2 TN  3 SN
encode term, gen(termcat) label(order)
drop term

gen QE = 0
*start of QE, see: https://www.ecb.europa.eu/mopo/implement/app/html/index.en.html#pspp
replace QE = 1 if dateSTATA > date("08.03.2015","DMY") 

egen panelid = group(isincat termcat ecbaccesslender)
xtset panelid dateSTATA

* Step 2: Add information on EONIA
* download daily data from, for example, Bloomberg / Thomson Reuters and replace code below:
gen EONIA=0.5 // create pseudodata

* Step 3: Calculate changes:
bysort panelid (dateSTATA): gen delrSpecial = log(volweightedrate[_n]/volweightedrate[_n-1])
bysort panelid (dateSTATA): gen delrSpecialtm1 = log(volweightedrate[_n-1]/volweightedrate[_n-2])
bysort panelid (dateSTATA): gen delMMRate = log(EONIA[_n]/EONIA[_n-1])

* Step 4: Calculate additional regression inputs:
gen delMMRate_QE = delMMRate*QE
gen delMMRate_hypelig = delMMRate*hypeligible
gen delMMRate_hypelig_QE = delMMRate*hypeligible*QE

** Regressions

* All  
eststo clear
sort termcat
eststo R3a, title("TN/SN"): reghdfe delrSpecial delMMRate QE delMMRate_QE delrSpecialtm1, absorb(isincat##year##month##termcat) vce(robust) nocons
eststo R3b, title("TN/SN"): reghdfe delrSpecial delMMRate hypeligible delMMRate_hypelig delMMRate_hypelig_QE delrSpecialtm1, absorb(isincat##year##month##termcat) vce(robust) nocons
eststo R3c, title("TN/SN"): reghdfe delrSpecial delMMRate QE delMMRate_QE hypeligible delMMRate_hypelig delMMRate_hypelig_QE delrSpecialtm1, absorb(isincat##year##month##termcat) vce(robust) nocons

* Core
keep if (country=="DE"|country=="FR"|country=="BE"|country=="NL"|country=="FI"|country=="AT")
sort termcat
eststo R2a, title("TN/SN"): reghdfe delrSpecial delMMRate QE delMMRate_QE delrSpecialtm1, absorb(isincat##year##month##termcat) vce(robust) nocons
eststo R2b, title("TN/SN"): reghdfe delrSpecial delMMRate hypeligible delMMRate_hypelig delMMRate_hypelig_QE delrSpecialtm1, absorb(isincat##year##month##termcat) vce(robust) nocons
eststo R2c, title("TN/SN"): reghdfe delrSpecial delMMRate QE delMMRate_QE hypeligible delMMRate_hypelig delMMRate_hypelig_QE delrSpecialtm1, absorb(isincat##year##month##termcat) vce(robust) nocons

* DE
keep if (country=="DE")
sort termcat
eststo R1a, title("TN/SN"): reghdfe delrSpecial delMMRate QE delMMRate_QE delrSpecialtm1, absorb(isincat##year##month##termcat) vce(robust) nocons
eststo R1b, title("TN/SN"): reghdfe delrSpecial delMMRate hypeligible delMMRate_hypelig delMMRate_hypelig_QE delrSpecialtm1, absorb(isincat##year##month##termcat) vce(robust) nocons
eststo R1c, title("TN/SN"): reghdfe delrSpecial delMMRate QE delMMRate_QE hypeligible delMMRate_hypelig delMMRate_hypelig_QE delrSpecialtm1, absorb(isincat##year##month##termcat) vce(robust) nocons
